package org.linlinjava.litemall.admin.web.order_manage;

import org.linlinjava.litemall.admin.constant.HeaderConstant;
import org.linlinjava.litemall.admin.service.order_manage.AgedmallOnlineServices;
import org.linlinjava.litemall.admin.vo.online_service.*;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * @author wj
 * @date 2021/8/6 18:01
 */
@RestController
@RequestMapping("/service")
public class AgedmallOnlineController {

    @Resource
    private AgedmallOnlineServices agedmallOnlineServices;

    /**
     * 新增/编辑在线服务
     * @return
     */
    @PostMapping("/addOnlineService")
    public Object addOnlineService(@RequestBody @Validated AddOnlineServiceVo addOnlineServiceVo){
       return agedmallOnlineServices.addOnlineService(addOnlineServiceVo);
    }

    /**
     *  删除在线服务
     * @return
     */
    @PostMapping("/deleteService")
    public Object deleteService(@RequestBody @Validated @Size(min = 1,message = "id不能为空") List<Long> idList){
       return agedmallOnlineServices.deleteService(idList);
    }

    /**
     * 在线服务列表
     * @return
     */
    @GetMapping("/onlineServiceList")
    public Object onlineServiceList(ServiceListVo serviceListVo){
        return agedmallOnlineServices.onlineServiceList(serviceListVo);
    }

    /**
     * 增加/编辑该服务的运营城市
     */
    @PostMapping("/addOnlineServiceCity")
    public Object addOnlineServiceCity(@RequestBody @Validated OnlineServiceCityVo onlineServiceCityVo){
        return agedmallOnlineServices.addOnlineServiceCity(onlineServiceCityVo);
    }

    /**
     * 加载该服务的运营城市页面
     * @return
     */
    @PostMapping("/loadOnlineServiceCity/{type}/{id}")
    public Object loadOnlineServiceCity(@PathVariable @Validated String type,@PathVariable @Validated @NotBlank(message = "服务或运营城市id不能为空") String id){
        return agedmallOnlineServices.loadOnlineServiceCity(type,id);
    }

    /**
     * 用于获取服务运营城市/为运营城市的列表
     */
    @PostMapping("/onlineServiceCityList")
    public Object onlineServiceCityList(@RequestBody @Validated OnlineServiceCityListVo onlineServiceCityListVo){
        return agedmallOnlineServices.onlineServiceCityList(onlineServiceCityListVo);
    }


    /**
     * 用于获取服务运营城市/不为运营城市的列表
     */
    @PostMapping("/unlinkCityList")
    public Object unlinkCityList(@RequestBody @Validated UnlinkCityListVo unlinkCityListVo){
        return agedmallOnlineServices.unlinkCityList(unlinkCityListVo);
    }

    /**
     * 取消运营
     */
    @PostMapping("/cancleOnlineServiceCity")
    public Object cancleOnlineServiceCity(@RequestBody @Validated @Size(min = 1,message = "服务id不能为空") List<Integer> ids){
        return agedmallOnlineServices.cancleOnlineServiceCity(ids);
    }

    /**
     * 更新在线服务上下架状态
     * @param changeStateVo
     * @return
     */
    @PostMapping("/changeState")
    public Object changeState(@RequestBody @Validated  ChangeStateVo changeStateVo){
        return agedmallOnlineServices.changeState(changeStateVo);
    }


    /**
     * 获取科室列表
     * @return
     */
    @GetMapping("/departmentList")
    public Object departmentList(DepartListVo departListVo){
        return agedmallOnlineServices.departmentList(departListVo);
    }

    /**
     * 新增科室
     */
    @PostMapping("/addDepartment")
    public Object addDepartment(@RequestBody AddDepartmentVo addDepartmentVo){
        return agedmallOnlineServices.addDepartment(addDepartmentVo);
    }

    /**
     * 删除科室
     * @return
     */
    @PostMapping("/deleteDepartment")
    public Object deleteDepartment(@RequestBody List<String> departmentIds){
        return agedmallOnlineServices.deleteDepartment(departmentIds);
    }

    /**
     * 排班查询
     * @return
     */
    @GetMapping("/shiftTable/serviceCity")
    public Object serviceCity( @Validated ShiftTableServiceVo shiftTableServiceVo){
        return agedmallOnlineServices.serviceCity(shiftTableServiceVo);
    }


    /**
     * 排班查询-医生
     * @return
     */
    @GetMapping("/shiftTable/serviceCityDoctor")
    public Object serviceCityDoctor(@Validated ShiftTableServiceVo shiftTableServiceVo){
        return agedmallOnlineServices.serviceCityDoctor(shiftTableServiceVo);
    }


    /**
     * 某个日期和后一天的排班列表
     * @return
     */
    @GetMapping("/appointService/serviceCity")
    public Object appointService(@Validated  AppointServiceVo appointServiceVo){
        return agedmallOnlineServices.appointService(appointServiceVo);
    }





    /**
     * 添加/编辑医生
     */
    @PostMapping("/addDoctor")
    public Object addDoctor(@RequestBody @Validated AddDoctorVo addDoctorVo){
        return agedmallOnlineServices.addDoctor(addDoctorVo);
    }

    /**
     * 删除医生
     */
    @PostMapping("/deleteDoctor")
    public Object deleteDoctor(@RequestBody @Validated @Size(min = 1,message = "医生不能为空") List<String> ids){
        return agedmallOnlineServices.deleteDoctor(ids);
    }

    /**
     * 新增服务时间模板
     */
    @PostMapping("/addServiceTime")
    public Object addServiceTime(@RequestBody @Validated AddServiceTimeVo addServiceTimeVo){
        return agedmallOnlineServices.addServiceTime(addServiceTimeVo);
    }

    /**
     * 医生列表
     */
    @PostMapping("/doctorList")
    public Object doctorList(@RequestBody @Validated DoctorListVo doctorListVo){
        return agedmallOnlineServices.doctorList(doctorListVo);
    }

    /**
     * 累计订单/累计收入详情列表页
     * @return
     */
    @GetMapping("/serviceCountList")
    public Object serviceCountList(@Validated @NotNull(message = "医生id不能为空") Integer doctorId){
        return agedmallOnlineServices.serviceCountList(doctorId);
    }


    /**
     * 根据服务城市id查询服务列表
     */
    @GetMapping("/getServiceByCityId")
    public Object getServiceByCityId(@Validated SearchServiceByCityVo searchServiceByCityVo, HttpServletRequest request){
        Integer busiId = request.getIntHeader(HeaderConstant.HEADER_BUSIID);
        if (busiId == -1) {
            return ResponseUtil.unauthz();
        }
        searchServiceByCityVo.setShopId(busiId);
        return agedmallOnlineServices.getServiceByCityId(searchServiceByCityVo);
    }

    /**
     * 获取时间模板列表
     */
    @GetMapping("/getServiceTimeList")
    public Object getServiceTimeList(@Validated  ServiceTimeVo serviceTimeVo){
        return  agedmallOnlineServices.getServiceTimeList(serviceTimeVo);
    }


    /**
     *  获取服务列表已经拥有的分类-树结构
     */
    @GetMapping("/getClassByService")
    public Object getClassByService(@Validated @NotNull(message = "店铺id不能为空") Integer shopId){
        return  agedmallOnlineServices.getClassByService(shopId);
    }


    /**
     *  订单重新选择医生-加载服务限制时间
     * @return
     */
    @GetMapping("/loadDoctorDate")
    public Object loadDoctorDate(@Validated @NotNull(message = "服务id不能为空") Integer serviceId){
        return agedmallOnlineServices.loadDoctorDate(serviceId);
    }

    /**
     * 分配医生列表
     */
    @GetMapping("/descriptDoctorList")
    public Object descriptDoctorList(@Validated DescriptDoctorListVo descriptDoctorListVo){
        return agedmallOnlineServices.descriptDoctorList(descriptDoctorListVo);
    }

    /**
     * 分配医生列表
     */
    @PostMapping("/getInfo")
    public Object getInfo(@RequestBody @Validated OnlineServiceInfoVo  onlineServiceInfoVo){
        return agedmallOnlineServices.getInfo(onlineServiceInfoVo);
    }




}
